package com.ss.bilibili_online.repository;

import com.ss.bilibili_online.entity.BilibiliWebOnlineCount;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
public interface DataRepository extends JpaRepository<BilibiliWebOnlineCount,Integer> {

    @Query(value = "select * from bilibili_user_count b ORDER BY b.id DESC LIMIT ?1 ", nativeQuery=true)
    List<BilibiliWebOnlineCount> queryOnlineCount(int counts);
    //@Query(value = "select * from (select @row\\:= @row+1 as row,t.* from bilibili_user_count t,(select @row \\:= 0)r) t where t.row mod 60 =1 ORDER BY t.id DESC LIMIT ?1", nativeQuery=true)
    //@Query(value = "select * from  bilibili_user_count t  where t.id mod 60 =1 ORDER BY t.id DESC LIMIT ?1", nativeQuery=true)
    @Query(value = "select * from  bilibili_user_count_60 t  ORDER BY t.id DESC LIMIT ?1", nativeQuery=true)

    List<BilibiliWebOnlineCount> queryOnlineCountOverMinuter(int counts);
}
